home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
recent2
/
yamtools.lha
/
yamtools1.4
/
YTArcMove.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-03-28
|
17KB
|
458 lines
/******************************************************************************/
/* */
/* YTARCMOVE */
/* Copyright ©1997 by Dick Whiting */
/* */
/*----------------------------------------------------------------------------*/
/* This script requires YAMTOOLS for it to work. If you don't have YAMTOOLS */
/* you can get it on Aminet in directory comm/mail. This script allows you */
/* to archive all selected mail to a folder. This is only really useful from */
/* the mail list of a SEARCH. Otherwise, use YAM's normal capabilities. */
/* */
/* WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!! */
/* */
/* This one as of Yam 1.3.4 MAY be breaking some of Marcel's rules. I really */
/* don't know. This allows you to archive FROM ANY folder TO any folder other */
/* than INCOMING,SENT, and OUTGOING. I calculate the new name according to */
/* what I have surmised Marcel does. No Guarantees that this is entirely */
/* compatible with the way Marcel intended. Hope so. */
/* */
/* Version 1.1 of YTARCMOVE includes a test for the YAM version, which kill */
/* this script if the YAM version is greater than 1.3.x If (and I don't */
/* think so) there is a need for this script for later versions of YAM, then */
/* I will rewrite it as necessary. - Dick */
/* */
/*----------------------------------------------------------------------------*/
/* */
/* Standard Disclaimer: I wrote it, it works for me, I don't guarantee */
/* that it will do anything productive for anyone else, etc. etc. ;-) */
/* */
/*HOWEVER, if you DO find a use for it: I homeschool my kids and they */
/*would love a postcard from where EVER you live. */
/* */
/*Instant GEOGRAPHY lesson;) */
/* */
/* */
/*POSTCARDS: Dick Whiting */
/* 28590 S. Beavercreek Rd. */
/* Mulino, Oregon 97042 */
/* USA */
/* */
/*----------------------------------------------------------------------------*/
/* */
/* Address Bug Reports or Comments to: */
/* Dick Whiting <dwhiting@europa.com> */
/* 11 March 1997 */
/* */
/******************************************************************************/
/*
$VER: 1.1 Copyright ©1997 by Dick Whiting
$AUTHOR: Dick Whiting
$DESCRIPTION: Archiver-Mover for use with YAMTOOLS
*/
options results
options failat 21
targarch=''
targanum=''
targdir=''
parse arg targarch ',' targanum ',' targdir
MUIA_List_Format = 0x80423c0a
MUIA_List_Entries = 0x80421654
MUIA_VertWeight = 0x804298d0
MUIA_Window_DepthGadget = 0x80421923
MUIA_Window_DragBar = 0x8042045d
MUIA_Window_PublicScreen = 0x804278e4
MUIA_Window_SizeGadget = 0x8042e33d
TRUE=1
FALSE=0
MUIV_List_Insert_Active = -1
help.SQUIT=''
node.SQUIT=''
help.STEXT=''
node.STEXT=''
help.ARCHF=''
node.ARCHF=''
missing='.'
goodver='1.3' /* this script is valid for YAM 1.3.x */
Address YAMTOOLS
Call CheckYam
Select
when targarch='' then do
Call CheckMailList
Call ArchWindow
Call DisplayArchs
end
otherwise do
Call ProcessArchs
end
end
exit
/**************************************************************************/
/* Check that there is some mail to process */
/**************************************************************************/
CheckMailList:
list ID MLST ATTRS MUIA_List_Entries
mcnt=result
if mcnt=0 then do
errmsg='You need to CHOOSE mail to Archive'
Call ErrorMsg
end
Return
/**************************************************************************/
/* Display list of Archives */
/**************************************************************************/
/* Don't allow Incoming, Outgoing, Sent as target folders */
/**************************************************************************/
DisplayArchs:
list ID ALST ATTRS MUIA_List_Entries
acnt=result
do i=3 to acnt-1
list ID ALST POS i
aline=result
if aline='' then break
parse var aline arch ',' size ',' file ',' anum ',' rest
liststr=arch','anum','file
list ID ARCHF INSERT POS MUIV_List_Insert_Bottom STRING liststr
end
Return
/**************************************************************************/
/* Process Archivals */
/**************************************************************************/
ProcessArchs:
if targanum < 3 then do
errmsg="\033b"targarch "\033nis not a valid target for archiving"
Call ErrorMsg
end
window ID YTARC close
infotitle='"YAM Tools Info"'
infotext='\033nDoing Archiving and Moving...'
infobuttons='"Continue,Interrupt,Abort"'
showbusy=TRUE
Call InfoWindow
list ID MLST ATTRS MUIA_List_Entries
mcnt=result
archlist.=missing
archlist.0=0
Updlist.=missing
Updlist.0=0
acnt=0
/**************************************************************************/
/* build list of mail to archive */
/**************************************************************************/
do i=0 to mcnt-1
list ID MLST
mline=result
if mline='' then break
parse var mline arch ',' from ',' subj ',' mfor ',' mnum ',' anum ',' file
acnt=acnt+1
anum=right(anum,6,'0')
mnum=right(mnum,6,'0')
Archlist.0=acnt
Archlist.acnt=anum mnum file subj
archlist.0=acnt
radio ID SQUIT
if result~="Continue" then signal ProcessArchsEnd
end
Updlist.0=Archlist.0
if acnt=0 then do
errmsg='You need to SELECT mail to Archive'
Call ErrorMsg
end
/**************************************************************************/
/* sort the list in preparation */
/**************************************************************************/
if show('L','rexxtricks.library') then do /* use tricks library */
call QSORT(archlist) /* sort by name, line number */
end
else do /* use QuickSort format */
call QSORT(1, archlist.0, archlist) /* sort by name, number */
end
radio ID SQUIT
if result~="Continue" then signal ProcessArchsEnd
/**************************************************************************/
/* Loop thru mail verifying nothing has changed */
/* do it in reverse order to keep from rearranging list */
/**************************************************************************/
do i=archlist.0 to 1 by -1 /* process in reverse order */
radio ID SQUIT
if result~="Continue" then leave /* skip remaining & do cleanup */
anum=word(Archlist.i,1)
anum=strip(anum,'L','0')
if anum='' then anum=0
mnum=word(Archlist.i,2)
mnum=strip(mnum,'L','0')
if mnum='' then mnum=0
file=word(Archlist.i,3)
subj=subword(Archlist.i,4)
Updlist.i=anum
Updlist.i.1=mnum
Updlist.i.1.1=file
Updlist.i.1.1.1=subj
Address YAM 'setfolder 'anum /* goto folder */
Address YAM 'setmail 'mnum /* set to mail */
Address YAM "getmailinfo file" /* verify filename */
xfile=result
fullfile=xfile /* copy complete path/fn */
xlen=length(file)
xfile=right(xfile,xlen)
Address YAM "getmailinfo subject" /* verify subject */
xsubj=result
xsubj=translate(xsubj,' ',',')
if file~=xfile | xsubj~=subj then do
Updlist.i.1.1.1.1='\033berror'
end
else do
if anum=0 then do /* use ARCHIVE cmd for Incoming */
Address YAM "mailarchive " targanum
Updlist.i.1.1.1.1='\033barchived'
end
else do /* Handle others */
Call MoveIt
end
end
end
/**************************************************************************/
/* Update target and source folders */
/**************************************************************************/
infotext='\033nUpdating Folder Indexes...'
text ID STEXT LABEL infotext
Address YAM 'setfolder 'targanum /* set to target folder */
Address YAM 'mailupdate' /* update the index */
oldarch=missing /* level break control */
do i=1 to Updlist.0
if Updlist.i~=oldarch then do
Address YAM 'setfolder ' Updlist.i /* goto folder */
Address YAM 'mailupdate' /* update the index */
oldarch=Updlist.i
end
end
/**************************************************************************/
/* Update list of mail archived/moved */
/**************************************************************************/
infotext='\033nUpdating Mail Status...'
text ID STEXT LABEL infotext
do i=1 to Updlist.0 /* display status messages */
do j=0 to mcnt-1
list ID MLST POS j
mline=result
if mline='' then break
parse var mline arch ',' from ',' subj ',' mfor ',' mnum ',' anum ',' file
if Updlist.i=anum & Updlist.i.1=mnum then do
if Updlist.i.1.1.1.1~=missing then arch=Updlist.i.1.1.1.1
mline=arch||','||from||','||subj||','||mfor||','||mnum||','||anum||','||file
list ID MLST POS j STRING mline
iterate i
end
end
end
ProcessArchsEnd:
window ID YTINF CLOSE
Return
/**************************************************************************/
/* Find the LAST filename in the target dir, calculate new name, do a DOS */
/* COPY command for output and a DOS delete command for the input. */
/* !! DON'T USE 'i' as a pointer in this routine */
/**************************************************************************/
MoveIt:
targfn=right(date('I'),5,'0')
dirlist=showdir(targdir,'FILE')
highfile='.index'
do filecnt=1 to words(dirlist)
if word(dirlist,filecnt) > highfile then do
highfile=word(dirlist,filecnt)
end
end
highname=substr(highfile,1,5)
highext=substr(highfile,7,3)
if targfn>highname then do
highname=targfn
highext='001'
end
else do
highext=highext+1
highext=right(highext,3,'0')
end
if highext='000' then do /* gone over 999 */
highname=right(highname+1,5,'0') /* use next days date */
highext='001' /* new series */
end
Address Command 'Copy ' fullfile 'TO' targdir'/'highname'.'highext 'QUIET CLONE'
if rc=0 then do
Updlist.i.1.1.1.1='\033bmoved'
Address Command 'Delete ' fullfile 'QUIET'
end
else do
Updlist.i.1.1.1.1='\033berror'
end
Return
/**************************************************************************/
/* Make sure YAM and YAMTOOLS are running. Show YAM. */
/**************************************************************************/
CheckYAM:
if ~show('p','YAMTOOLS') then do
errmsg='You need YAMTOOLS running to use YTArcMove'
say errmsg
exit
end
if ~show('p','YAM') then do
errmsg='You need YAM running to use YTArcMove'
Call ErrorMsg
exit
end
Address YAM 'info version' /* check YAM's version */
yamver=word(result,3)
if left(yamver,3)~=goodver then do /* only 1.3.x or lower valid */
errmsg='This script is not valid for YAM 'yamver
Call ErrorMsg
exit
end
Address YAM 'show' /* uniconify YAM's screen */
Address YAM 'info SCREEN' /* get YAM's screen */
screen=result
if screen='' then screen='Workbench'
Return
/******************************************************************************/
/* Display ERROR message and EXIT. */
/******************************************************************************/
ErrorMsg:
window ID YTINF CLOSE
request ID ERRM GADGETS '"OK"' errmsg
exit
Return
/******************************************************************************/
/* Display list of Archives for archive target selection. */
/******************************************************************************/
ArchWindow:
window ID YTARC TITLE '"YAM Tools Archiver"',
COMMAND '"window ID YTARC close"' PORT YAMTOOLS,
ATTRS MUIA_Window_PublicScreen screen
group
group
text LABEL "\033c\033bSelect Target Folder For Archiving"
endgroup
group
list ID ARCHF COMMAND '"YTArcMove.rexx %s"',
HELP help.ARCHF NODE node.ARCHF,
TITLE '"\033bYam Folder Name,\033bNumber,"',
INSERT NODUP,
ATTRS MUIA_List_Format '"BAR,P=\033r,WEIGHT=0 MAXWIDTH=0 MINWIDTH=0"'
endgroup
endgroup
endwindow
Return
/******************************************************************************/
/* Simple information/error message window. */
/******************************************************************************/
InfoWindow:
window ID YTINF TITLE '"YAM Archiver Info"' ATTRS MUIA_Window_PublicScreen screen,
MUIA_Window_SizeGadget FALSE MUIA_Window_DragBar FALSE,
MUIA_Window_DepthGadget FALSE
group
group
text ID STEXT HELP help.STEXT NODE node.STEXT LABEL infotext
endgroup
if showbusy then do
group
object CLASS '"Busy.mcc"' ATTRS MUIA_VertWeight 25
endgroup
end
if infobuttons ~='' then do
group HORIZ
group
space HORIZ
endgroup
group
radio ID SQUIT HELP help.SQUIT NODE node.SQUIT LABELS infobuttons
endgroup
group
space HORIZ
endgroup
endgroup
end
else do
group
space HORIZ 100
endgroup
end
endgroup
endwindow
Return
/**************************************************************************/
/* End of Active Code */
/**************************************************************************/